<!-- 载入系统通用设置  -->
<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/common_setting_unit.php"); ?>





<div class="display:">
<?
//设置需要搜索的表格的前缀后缀 和 默认搜索排序
$table        = $table_Prefix . "contact";
$contact_nid = $_REQUEST['contact_nid'];
$system_part  = addslashes($_REQUEST ['sys_part']);
?>





    <?php

    //用来做图片对比，用于删除图片
    $old_detail=select_one_line_all_items($table_Prefix."contact","nid = ".$contact_nid);


    //这里是涉及上传文件的部分：包含图片和附件。视频也应该用这种形式上传
    //20220315同时把旧的文件，移动到delete中。
    //统一设置一下保存图片的路径
    $_uf['path']        = ROOT_PATH_ . "/uploadfiles/".$theme_folder."/";

    //创建删除文件存放文件夹
    if(!file_exists($_uf['path'] ."/delete/")){
        mkdir($_uf['path'] ."/delete/",0777,true);
        chmod($_uf['path'] ."/delete/",0777);
    }



    //上传Banner
    if (is_uploaded_file($_FILES['banner']['tmp_name']))
    {
        $_uf['upfile']       = $_FILES['banner'];
        $_info               = upload_file($_uf);
        $_REQUEST['ai_banner'] = $_info['name'];
        if(($_REQUEST['ai_banner'])&&($old_detail['banner']!="alpha.gif")){
            rename($_uf['path'].$old_detail['banner'], $_uf['path'] ."delete/".$old_detail['banner']);
        }
    }




    //上传qrcode
    if (is_uploaded_file($_FILES['qrcode']['tmp_name']))
    {
        $_uf['upfile']       = $_FILES['qrcode'];
        $_info               = upload_file($_uf);
        $_REQUEST['ai_qrcode'] = $_info['name'];
        if(($_REQUEST['ai_qrcode'])&&($old_detail['qrcode']!="alpha.gif")){
            rename($_uf['path'].$old_detail['qrcode'], $_uf['path'] ."delete/".$old_detail['qrcode']);
        }
    }


    //上传抖音
    if (is_uploaded_file($_FILES['dycode']['tmp_name']))
    {
        $_uf['upfile']       = $_FILES['dycode'];
        $_info               = upload_file($_uf);
        $_REQUEST['ai_dycode'] = $_info['name'];
        if(($_REQUEST['ai_dycode'])&&($old_detail['dycode']!="alpha.gif")){
            rename($_uf['path'].$old_detail['dycode'], $_uf['path'] ."delete/".$old_detail['dycode']);
        }
    }



    //上传视频号二维码
    if (is_uploaded_file($_FILES['wxvcode']['tmp_name']))
    {
        $_uf['upfile']       = $_FILES['wxvcode'];
        $_info               = upload_file($_uf);
        $_REQUEST['ai_wxvcode'] = $_info['name'];
        if(($_REQUEST['ai_wxvcode'])&&($old_detail['wxvcode']!="alpha.gif")){
            rename($_uf['path'].$old_detail['wxvcode'], $_uf['path'] ."delete/".$old_detail['wxvcode']);
        }
    }


    ?>







<?php
//检验一下要插入表格的项，数据库科中是否存在对应的项
//这里可以foreach ai_来到循环检查插入。

$table        = $table_Prefix . "contact" ;
update_exists($table, "twitter", "1");
update_exists($table, "severtime", "1");
update_exists($table, "tumblr", "1");
update_exists($table, "pinterest", "1");
update_exists($table, "whatsapp", "1");
update_exists($table, "google", "1");
update_exists($table, "twitter", "1");
update_exists($table, "facebook", "1");
update_exists($table, "linkedin", "1");
update_exists($table, "youtube", "1");
update_exists($table, '`instagram`', 1);
update_exists($table, '`map`', 1);


$updatestr=update_date($table_Prefix . "contact",$_REQUEST,"nid",0);


sql_log($updatestr);
$query = mysql_query($updatestr) or die ("error:".mysql_error());
mysql_close($con);

?>



<script type="text/javascript">
    alert("输入信息已保存，点击确认返回继续操作.");
    document.location.href = "detail-edit.php?sys_part=<? echo $system_part ?>";
</script>

</div>